const fs = require('fs');

function route(pathname,res) {
    switch (pathname) {
        case '/login': {
            res.writeHead(200, {
                'Content-Type': 'text/html;charset=utf-8'
            });
            res.write(fs.readFileSync('./static/login.html', 'utf-8'));
            break;
        }
        case '/index': {
            res.writeHead(200, {
                'Content-Type': 'text/html;charset=utf-8'
            });
            res.write(fs.readFileSync('./static/index.html', 'utf-8'));
            break;
        }
        default: {
            res.writeHead(200, {
                'Content-Type': 'text/html;charset=utf-8'
            });
            res.write(fs.readFileSync('./static/404.html', 'utf-8'));
            break;
        }
    }
}

module.exports = route;